/* MASTER FILE for: Francisco Costa, Angelo Marcantonio, Rudi Rocha.  Stop Suffering! Economic Downturns and Pentecostal Upsurge. Journal of the European Economic Association, 2022.  */
/* Files numbered in running order. Letters correspond to appendix material */
/* Auxiliary files start with '_' */
/* You need Stata and Python to replicate all codes */
/* Codes 15-20 use identified data that we cannot share in this replication package */

/* Create a folder with the following structure:
	\codes\
	\data\input\
	\data\tmp\
	\data\workfiles\
	\output\logs\
	\output\figures\
	\output\tables\
  First unzip all zipped data files in the \data\input\ folder and the codes in the \codes\ folder */

/* Update the folder path in line 11 below */

set more, perm

*global dirdata "PATHDATA" //for identified data
global dirpath "..UPDATEPATH\CMR_Pentecostals_replication"
cd $dirpath

***

* Creating workfiles
/* Census data opened and compatibilized using DatasZoom (PUC-Rio): http://www.econ.puc-rio.br/datazoom/english/censo.html */
do "codes/01 create religion variables 1980.do" 
do "codes/02 create religion variables 1991.do" 
do "codes/03 create religion variables 2000.do" 
do "codes/04 create religion variables 2010.do" 
***

do "codes/05 create regional tariff reduction.do"  
do "codes/06 create controls and earnings 1980.do" 
do "codes/07 create controls and earnings 1991.do" 
do "codes/08 create earnings 2000.do" 
do "codes/09 create earnings 2010.do" 
***

do "codes/10 clean suicide data.do" 
do "codes/11 create workfile.do" 	
do "codes/12 create workfile by cohort.do" 
do "codes/13 create workfile by demographics.do" 
***

do "codes/14 main regressions.do" 

/* * codes using restricted data *
do "codes/15 PYTHON CNPJ select_religious_institutions.ipynb" 	
do "codes/16 create CNPJ panel.do" 								
do "codes/17 create clubs CNPJ panel.do" 						
do "codes/18 select CNPJs in RAIS.do" 							
do "codes/19 PYTHON select_religious_institutions_based_on_rais .ipynb" 
do "codes/20 create religious panel RAIS.do" */
do "codes/21 supply regression RAIS CNPJ.do" 
do "codes/23 regressions clubs.do" 
do "codes/24 Descriptive Stat Table.do" 

***

do "codes/25 TSE opendata 1994.do" 
do "codes/26 TSE opendata 1998.do" 
do "codes/27 TSE opendata 2002.do" 
do "codes/28 TSE opendata 2006.do" 
do "codes/29 TSE opendata 2010.do" 
do "codes/30 TSE opendata 2014.do" 
do "codes/31 TSE opendata 2018.do" 
do "codes/32 TSE opendata president.do" 
do "codes/33 PYTHON TSE camara_opening_data.ipynb" 
do "codes/34 opendata proposicoes.do" 

***
do "codes/35 TSE Referendum.do" 
do "codes/36 TSE regression federal deputies.do" 
do "codes/37 TSE regression Presidential counterfactual.do" 
do "codes/38 TSE regression proposicoes.do" 
do "codes/39 TSE Descriptive Stat Table.do" 
do "codes/40 descriptive figures.do" 		
***

do "codes/A1 migration create earnings 1980.do"  
do "codes/A2 migration create earnings 1991.do" 
do "codes/A3 migration create earnings 2000.do" 
do "codes/A4 migration create earnings 2010.do" 
do "codes/A5 migration create religion variables 1980.do" 
do "codes/A6 migration create religion variables 1991.do" 
do "codes/A7 migration create religion variables 2000.do" 
do "codes/A8 migration create religion variables 2010.do" 
do "codes/A9 migration create workfiles.do" 
do "codes/A10 migration regressions.do" 	
***

do "codes/A11 suicide analysis.do" 	
do "codes/A12 tables appendix D.do" 

* END
